home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Graphics Programming (2nd Edition) / Visual Basic Graphics Programming 2nd Edition.iso / OldSrc / CH8 / SRC / TILE.FRM (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1996-03-12  |  5.5 KB  |  195 lines

  1. VERSION 4.00
  2. Begin VB.Form TileForm 
  3.    Caption         =   "Tile"
  4.    ClientHeight    =   4350
  5.    ClientLeft      =   1740
  6.    ClientTop       =   1185
  7.    ClientWidth     =   5655
  8.    Height          =   5040
  9.    Left            =   1680
  10.    LinkTopic       =   "Form1"
  11.    ScaleHeight     =   290
  12.    ScaleMode       =   3  'Pixel
  13.    ScaleWidth      =   377
  14.    Top             =   555
  15.    Width           =   5775
  16.    Begin VB.PictureBox Canvas 
  17.       AutoRedraw      =   -1  'True
  18.       Height          =   4335
  19.       Left            =   1320
  20.       ScaleHeight     =   285
  21.       ScaleMode       =   3  'Pixel
  22.       ScaleWidth      =   285
  23.       TabIndex        =   0
  24.       Top             =   0
  25.       Width           =   4335
  26.    End
  27.    Begin VB.Image Tile 
  28.       Height          =   480
  29.       Index           =   2
  30.       Left            =   0
  31.       Picture         =   "Tile.frx":0000
  32.       Top             =   1200
  33.       Width           =   480
  34.    End
  35.    Begin VB.Image Tile 
  36.       Height          =   480
  37.       Index           =   1
  38.       Left            =   0
  39.       Picture         =   "Tile.frx":0282
  40.       Top             =   600
  41.       Width           =   480
  42.    End
  43.    Begin VB.Image Tile 
  44.       Height          =   420
  45.       Index           =   7
  46.       Left            =   600
  47.       Picture         =   "Tile.frx":0504
  48.       Top             =   0
  49.       Width           =   420
  50.    End
  51.    Begin VB.Image Tile 
  52.       Height          =   480
  53.       Index           =   0
  54.       Left            =   0
  55.       Picture         =   "Tile.frx":0746
  56.       Top             =   0
  57.       Width           =   480
  58.    End
  59.    Begin VB.Image Tile 
  60.       Height          =   450
  61.       Index           =   5
  62.       Left            =   0
  63.       Picture         =   "Tile.frx":09C8
  64.       Top             =   3000
  65.       Width           =   450
  66.    End
  67.    Begin VB.Image Tile 
  68.       Height          =   420
  69.       Index           =   6
  70.       Left            =   0
  71.       Picture         =   "Tile.frx":0C2A
  72.       Top             =   3600
  73.       Width           =   360
  74.    End
  75.    Begin VB.Image Tile 
  76.       Height          =   600
  77.       Index           =   13
  78.       Left            =   600
  79.       Picture         =   "Tile.frx":0DFC
  80.       Top             =   3720
  81.       Width           =   600
  82.    End
  83.    Begin VB.Image Tile 
  84.       Height          =   600
  85.       Index           =   12
  86.       Left            =   600
  87.       Picture         =   "Tile.frx":119E
  88.       Top             =   3000
  89.       Width           =   600
  90.    End
  91.    Begin VB.Image Tile 
  92.       Height          =   600
  93.       Index           =   11
  94.       Left            =   600
  95.       Picture         =   "Tile.frx":1540
  96.       Top             =   2280
  97.       Width           =   600
  98.    End
  99.    Begin VB.Image Tile 
  100.       Height          =   480
  101.       Index           =   8
  102.       Left            =   600
  103.       Picture         =   "Tile.frx":18E2
  104.       Top             =   480
  105.       Width           =   480
  106.    End
  107.    Begin VB.Image Tile 
  108.       Height          =   480
  109.       Index           =   4
  110.       Left            =   0
  111.       Picture         =   "Tile.frx":1B64
  112.       Top             =   2400
  113.       Width           =   480
  114.    End
  115.    Begin VB.Image Tile 
  116.       Height          =   480
  117.       Index           =   3
  118.       Left            =   0
  119.       Picture         =   "Tile.frx":1DE6
  120.       Top             =   1800
  121.       Width           =   480
  122.    End
  123.    Begin VB.Image Tile 
  124.       Height          =   480
  125.       Index           =   10
  126.       Left            =   600
  127.       Picture         =   "Tile.frx":2068
  128.       Top             =   1680
  129.       Width           =   480
  130.    End
  131.    Begin VB.Image Tile 
  132.       Height          =   480
  133.       Index           =   9
  134.       Left            =   600
  135.       Picture         =   "Tile.frx":22EA
  136.       Top             =   1080
  137.       Width           =   480
  138.    End
  139.    Begin VB.Menu mnuFile 
  140.       Caption         =   "&File"
  141.       Begin VB.Menu mnuFileExit 
  142.          Caption         =   "E&xit"
  143.       End
  144.    End
  145. Attribute VB_Name = "TileForm"
  146. Attribute VB_Creatable = False
  147. Attribute VB_Exposed = False
  148. Option Explicit
  149. Dim TileChoice As Integer
  150. ' ************************************************
  151. ' Tile the control with the Tile.
  152. ' ************************************************
  153. Sub TilePicture(pic As PictureBox, tile_image As Image)
  154. Dim wid As Integer
  155. Dim hgt As Integer
  156. Dim rows As Integer
  157. Dim cols As Integer
  158. Dim r As Integer
  159. Dim c As Integer
  160. Dim x As Integer
  161. Dim y As Integer
  162.     pic.Cls     ' Clear the picture box.
  163.     wid = tile_image.Width
  164.     hgt = tile_image.Height
  165.     ' See how many rows and columns we will need.
  166.     cols = Int(pic.ScaleWidth / wid + 1)
  167.     rows = Int(pic.ScaleHeight / hgt + 1)
  168.     ' Copy the tile.
  169.     y = 0
  170.     For r = 1 To rows
  171.         x = 0
  172.         For c = 1 To cols
  173.             pic.PaintPicture tile_image.Picture, x, y
  174.             x = x + wid
  175.         Next c
  176.         y = y + hgt
  177.     Next r
  178. End Sub
  179. ' ************************************************
  180. ' Tile the form.
  181. ' ************************************************
  182. Private Sub Form_Resize()
  183.     Canvas.Move Canvas.Left, 0, _
  184.         TileForm.ScaleWidth - Canvas.Left, _
  185.         TileForm.ScaleHeight
  186.     TilePicture Canvas, Tile(TileChoice)
  187. End Sub
  188. Private Sub mnuFileExit_Click()
  189.     Unload Me
  190. End Sub
  191. Private Sub Tile_Click(Index As Integer)
  192.     TileChoice = Index
  193.     TilePicture Canvas, Tile(Index)
  194. End Sub
  195.